/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
@import 'tensorboard/webapp/theme/tb_theme';

// 42px + 1px for border.
$_table-content-row-min-height: 43px;
$_font-size: 13px;

:host {
  display: flex;
  flex-direction: column;
  font-size: $_font-size;
  overflow: hidden;
}

.filter-row {
  flex: none;
}

.table-container {
  contain: layout paint;
  flex-grow: 1;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  will-change: scroll-position;
}

:host.flex-layout {
  .name {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  mat-paginator {
    border-top: 1px solid mat-color($tb-foreground, border);
    padding-bottom: 12px;
  }
}

$_border-color: #0000001f;

[role='table'] {
  display: table;
  width: 100%;

  .header {
    color: mat-color($tb-foreground, text);
    white-space: nowrap;

    // Allows table header to remain sticky to the scrollable container.
    [role='columnheader'] {
      background-color: mat-color($tb-background, background);
      position: sticky;
      top: 0;
      // Unlike <thead><tr>, we need to manually "lift" the elements up so it
      // masks table rows underneath.
      z-index: 1;
    }
  }

  [role='row'] {
    contain: strict;
    display: table-row;
    height: $_table-content-row-min-height;

    .column {
      border-bottom: 1px solid $_border-color;
      display: table-cell;

      padding: 5px;
      vertical-align: middle;

      &:first-child {
        padding-left: 24px;
      }

      &:last-child {
        padding-right: 24px;
      }
    }
  }
}

[role='rowgroup'] {
  display: table-row-group;

  &.header {
    display: table-header-group;
  }
}

.loading,
.no-runs {
  align-items: center;
  border: 0;
  border-bottom-width: 1px;
  border-color: $_border-color;
  border-style: solid;
  display: flex;
  height: 48px;
  padding: 0 24px;
}

.loading {
  justify-content: center;
}

.select-all th {
  padding-bottom: 12px;
  padding-top: 12px;
}

.select-all-content,
.select-all-content button {
  font-weight: 400;
  line-height: 1.6;
  text-align: left;
}

.select-all-content button {
  font-weight: 500;
  padding: 0 4px;
}

.filter-row {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 16px 0 21px;
  border-bottom: 1px solid mat-color($tb-foreground, border);

  tb-filter-input {
    flex-grow: 1;
  }
}

// Prevents the table column for checkbox and run_color from growing beyond
// their sizes.
.tb-column-checkbox,
.tb-column-run_color {
  width: 20px;
}

.tb-column-run_color {
  text-align: center;
}

.run-color-swatch {
  $_swatch-size: 20px;

  border-radius: 100%;
  border: 1px solid mat-color($tb-foreground, border);
  height: $_swatch-size;
  width: $_swatch-size;
  outline: none;

  &.no-color {
    border-color: mat-color($tf-slate, 300);
    border-width: 2px;
  }
}

.range-input-container {
  // Undo mat-menu-item's default 48px height.
  height: auto;
}

:host ::ng-deep mat-paginator mat-form-field {
  margin: 0;
}

.filter-menu-checkbox-row mat-checkbox ::ng-deep label {
  // Make mat-checkboxes in menus take up full row.
  display: flex;
  height: 100%;
  align-items: center;

  .mat-checkbox-inner-container {
    margin-left: 0;
  }

  .mat-checkbox-label {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
